<html>
  <head>
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <meta http-equiv="Content-Language" content="en" />
    <title>s6-linux-init: the s6-linux-init-shutdown program</title>
    <meta name="Description" content="s6-linux-init: the s6-linux-init-shutdown program" />
    <meta name="Keywords" content="s6 linux init administration root utilities shutdown halt poweroff reboot" />
    <!-- <link rel="stylesheet" type="text/css" href="//skarnet.org/default.css" /> -->
  </head>
<body>

<p>
<a href="index.html">s6-linux-init</a><br />
<a href="//skarnet.org/software/">Software</a><br />
<a href="//skarnet.org/">skarnet.org</a>
</p>

<h1> The <tt>s6-linux-init-shutdown</tt> program </h1>

<p>
<tt>s6-linux-init-shutdown</tt> triggers the system shutdown procedure.
It is normally invoked as <tt>/sbin/shutdown</tt>.
</p>

<h2> Interface </h2>

<pre>
     s6-linux-init-shutdown [ -h [ -H | -P ] | -p | -r | -k ] [ -a ] [ -t <em>sec</em> ] [ -i ] [ -f | -F ] <em>time</em> [ <em>message</em> ]
     s6-linux-init-shutdown -c [ <em>message</em> ]
</pre>

<ul>
 <li> If the <tt>-c</tt> option is present, a pending shutdown is cancelled. </li>
 <li> Else, it plans the shutdown procedure at time <em>time</em>. </li>
 <li> If a <em>message</em> argument has been given, <em>message</em> is
broadcast to all logged in users (as tracked by utmp). </li>
 <li> <tt>shutdown</tt> exits 0. The shutdown procedure happens asynchronously. </li>
</ul>

<p>
 The <tt>s6-linux-init-shutdown</tt> program conforms to the LSB-3.0.0
<a href="https://refspecs.linuxbase.org/LSB_3.0.0/LSB-PDA/LSB-PDA/shutdown.html">shutdown</a>
interface.
</p>

<p>
 <em>time</em> must follow the following format:
<tt>[&nbsp;now&nbsp;|&nbsp;[+]<em>mins</em>&nbsp;|&nbsp;<em>hh</em>:<em>mm</em>&nbsp;]</tt>
</p>

<ul>
 <li> <tt>now</tt> means: trigger the shutdown sequence immediately. </li>
 <li> <em>hh</em>:<em>mm</em> means: absolute time. Trigger the shutdown sequence when the time
<em>hh</em>:<em>mm</em> occurs. If that time has passed for the day, it will wait for the
next day. <em>hh</em> must have 1 or 2 digits; <em>mm</em> must have 2 digits. </li>
 <li> <em>mins</em> or <tt>+</tt><em>mins</em> means: relative time. Trigger the shutdown
sequence after <em>mins</em> minutes. </li>
</ul>

<h2> Options </h2>

<ul>
 <li> <tt>-a</tt>&nbsp;: access control. The shutdown sequence will only be
launched if one of the users listed in <tt>/etc/shutdown.allow</tt>
is currently logged in (as tracked by utmp). <tt>/etc/shutdown.allow</tt>
is a text file, one user per line, lines starting with <tt>#</tt> are comments. </li>
 <li> <tt>-t</tt>&nbsp;<em>sec</em>&nbsp;: at the end of the shutdown sequence,
when it's time to kill all processes, have a "grace time" period
of <em>sec</em> seconds between the SIGTERM and the SIGKILL (to allow processes
receiving SIGTERM to exit cleanly). Default is 3 seconds. </li>
 <li> <tt>-k</tt>&nbsp;: warning only. <em>message</em> will be sent to all
logged in users, but the shutdown sequence will not be triggered. </li>
 <li> <tt>-h</tt>&nbsp;: at the end of the shutdown sequence, halt the system. The
behaviour of this option may be altered with <tt>-H</tt> or <tt>-P</tt>. </li>
 <li> <tt>-p</tt>&nbsp;: at the end of the shutdown sequence, power off the system.
(This option is provided as an extension, it is not required by the LSB interface.) </li>
 <li> <tt>-r</tt>&nbsp;: at the end of the shutdown sequence, reboot the system. </li>
 <li> <tt>-f</tt>&nbsp;: ignored. </li>
 <li> <tt>-F</tt>&nbsp;: ignored. </li>
 <li> <tt>-c</tt>&nbsp;: cancel a planned shutdown (i.e. cancel the effect of a
previous call to <tt>shutdown</tt> with a <em>time</em> argument that was not <tt>now</tt>).
This cannot be used to interrupt a shutdown sequence that has already started. </li>
 <li> <tt>-H</tt>&nbsp;: this option can only be used in conjunction with <tt>-h</tt>.
Ensures the system is halted, not powered off, at the end of the shutdown sequence.
<tt>-Hh</tt> is equivalent to <tt>-h</tt>. </li>
 <li> <tt>-P</tt>&nbsp;: this option can only be used in conjunction with <tt>-h</tt>.
Ensures the system is powered off at the end of the shutdown sequence.
<tt>-Ph</tt> is equivalent to <tt>-p</tt>. </li>
 <li> <tt>-i</tt>&nbsp;: interactive confirmation request. The command needs to be
launched in a terminal, and will prompt the user to type the (short) hostname of
the machine to be shut down. On mismatch, the command will abort. The point is to
avoid inadvertently rebooting a remote machine in an ssh session. </li>
</ul>

<h2> Notes </h2>

<ul>
 <li> The <tt>s6-linux-init-shutdown</tt>
binary is not meant to be called directly by administrators. Instead, after a
<a href="s6-linux-init-maker.html">s6-linux-init-maker</a> invocation,
the <tt>bin/</tt> subdirectory of the target will contain a <tt>shutdown</tt>
symlink to <tt>s6-linux-init-shutdown</tt>. The <tt>bin/</tt> subdirectory
should be copied by the administrator into <tt>/sbin</tt> for full
interface compatibility with sysvinit. </li>
 <li> The <tt>-f</tt> and <tt>-F</tt> options are only accepted for compatibility.
LSB says they are used to advise the system to skip or enforce a <tt>fsck</tt>
after rebooting. But they are only advisory, and for decades now systems have used
other methods of evaluating whether they should perform filesystem checks, so these
options are largely obsolete nowadays. </li>
</ul>

</body>
</html>
